<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('接收plc发送来的状态列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
                            <li class="select-time">
                                <label>创建时间： </label>
                                <input type="text" class="input-sm form-control" id="startTime" placeholder="起始时间" name="beginTime"/>
                                <span>-</span>
                                <input type="text" class="input-sm form-control" id="endTime" placeholder="终止时间" name="endTime"/>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">
                <!--<a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="system:status:add">
                    <i class="fa fa-plus"></i> 添加
                </a>
                <a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="system:status:edit">
                    <i class="fa fa-edit"></i> 修改
                </a>
                <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="system:status:remove">
                    <i class="fa fa-remove"></i> 删除
                </a>-->
                <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="system:status:export">
                    <i class="fa fa-download"></i> 导出
                 </a>
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('system:status:edit')}]];
        var removeFlag = [[${@permission.hasPermi('system:status:remove')}]];

        var modelDatas = [[${@dict.getType('sys_plc_model')}]];
        var startStatusDatas = [[${@dict.getType('sys_is_start')}]];
        var countDatas = [[${@dict.getType('sys_start_cart')}]];
        var errorDatas = [[${@dict.getType('sys_error_cart')}]];
        var is_completeDatas = [[${@dict.getType('sys_result_cart')}]];

        var prefix = ctx + "system/status";

        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                modalName: "接收plc发送来的状态",
                columns: [{
                    checkbox: true
                },
                {
                    field : 'id', 
                    title : '序号',
                    visible: true
                },
                {
                    field : 'model', 
                    title : '模式',
                    visible: true,
                    formatter:function (value, row, index) {
                        if (value == 1){
                            return modelDatas[0].dictLabel;
                        }else if (value == 2){
                            return  modelDatas[1].dictLabel;
                        }else if (value == 0){
                            return  modelDatas[2].dictLabel;
                        }else {
                            return '未定义';
                        }

                    }
                },
                {
                    field : 'startStatus', 
                    title : '是否开启',
                    visible: true,
                    formatter:function (value,row,index) {
                        if ( value == 0){
                            return startStatusDatas[0].dictLabel;
                        }else if( value == 1){
                            return  startStatusDatas[1].dictLabel;
                        }else {
                            return '未定义';
                        }

                    }
                },
                {
                    field : 'count', 
                    title : '行车启动',
                    visible: true,
                    formatter:function (value,row,index) {
                        if (value == 1){
                            return countDatas[0].dictLabel;
                        }else if (value == 2){
                            return  countDatas[1].dictLabel;
                        }else if (value == 3){
                            return  countDatas[2].dictLabel;
                        }else {
                            return '未定义';
                        }
                    }
                },
                {
                    field : 'error', 
                    title : 'plc返回错误信息',
                    visible: true,
                    formatter:function (value,row,index) {
                        if (value == 1){
                            return errorDatas[0].dictLabel;
                        }else if (value == 2){
                            return  errorDatas[1].dictLabel;
                        }else if (value ==3){
                            return  errorDatas[2].dictLabel;
                        }else {
                            return '未定义';
                        }
                    }
                },
                {
                    field : 'is_complete', 
                    title : '行车放料完成',
                    visible: true,
                    formatter:function (value,row,index) {
                        if (value == 1){
                            return is_completeDatas[0].dictLabel;
                        }else if (value == 2){
                            return  is_completeDatas[1].dictLabel;
                        }else if (value ==3){
                            return is_completeDatas[2].dictLabel;
                        }else if (value == 4){
                            return is_completeDatas[0].dictLabel;
                        }else{
                            return '未定义';
                        }

                    }
                },
                {
                    field : 'create_time', 
                    title : '创建时间',
                    visible: true
                }]
            };
            $.table.init(options);
        });
    </script>
</body>
</html>